<template>
	<view class="layout">
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="left"  @click="choose(index)">
				<view class="check" :class="cur===index?'active':''"></view>
				<view class="time">{{item.title}} {{item.month}}月</view>
			</view>
			<view class="price">￥{{item.fee}}</view>
		</view>
		<view class="payNum"> 已有<text>{{count}}人</text>成功开通会员</view>
		<view class="btns" @click="submit">支付</view>
	</view>
</template>

<script>
import { vipApi } from '../../api/vip.js'
import storage from '../../utils/storage.js'
import { showLoading, hideLoading, toast } from '../../utils/util.js'
	export default {
		data(){
			return{
				list: [],
				count: 0,
				cur: -1
			}
		},
		onLoad(options){
			this.init()
		},
		methods: {
			init(){
				showLoading()
				vipApi.getVipList().then(res => {
					hideLoading()
					if(res.code === 200){
						if(res.data){
							this.list = res.data
							this.count = res.count
						}
					}
				})
			},
			choose(index){
				this.cur = index
			},
			submit(){
				if(storage.get('userInfo').isVip){
					return toast('您已经是会员')
				}
				let params = {
					vid: this.list[this.cur].id,
					type: 3,
					platform: 'wap'
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.layout{
		width: 100%;
		height: 100vh;
		background: #fff;
	}
	.item{
		padding: 20rpx 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.left{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			padding: 15rpx 0;
			.check{
				position: relative;
				width: 35rpx;
				height: 35rpx;
				border: 1rpx solid #FF814B;
				border-radius: 50%;
				&.active{
					border: none;
					&::before{
						content: '';
						position: absolute;
						left: 0;
						top: 0;
						width: 40rpx;
						height: 40rpx;
						background: url(../../static/images/choose1.png) no-repeat center;
						background-size: 40rpx 40rpx;
					}
				}
				
			}
			.time{
				padding-left: 20rpx;
				font-size: 30rpx;
				font-weight: 600;
				color: #333;
			}
		}
		.price{
			font-size: 30rpx;
			font-weight: 600;
			color: #FF814B;
		}
	}
	.payNum{
		padding: 10rpx 30rpx;
		font-size: 26rpx;
		color: #666;
		text{
			color: #FF814B;
			padding: 0 10rpx;
		}
	}
	.btns{
		width: 80%;
		margin: 50rpx auto 0;
		font-size: 30rpx;
		color: #fff;
		font-weight: 500;
	}
</style>